Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create index.d.ts #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Create index.d.ts #149

wants to merge 1 commit into from

Conversation

Palid
Copy link

@Palid Palid commented Nov 20, 2019

No description provided.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 463

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 81.337%

Totals Coverage Status
Change from base Build 459: 0.0%
Covered Lines: 1207
Relevant Lines: 1420

💛 - Coveralls

Copy link
Collaborator

@bevkoski bevkoski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution @Palid! I do have a few remarks and questions.

@@ -0,0 +1,48 @@
import React from 'react'
import { ReactNode } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this import is obsolete since you are only accessing ReactNode via React a few lines below.

export class ViewportAwarePlaceholder extends React.Component<ViewportAwarePlaceholderProps> {}



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you can unify the number of blank lines between the code blocks in the file. There are a total of 3 here and a total of 2 at line 9. One blank line is enough. Ideally, we should have TSLint setup, but that is not absolutely necessary at the moment.

import { ReactNode } from 'react';

export interface ViewportTrackerProps {
children: React.ReactNode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabWidth is set to 2 for JS files. It would be great if we can stick to the same for this file as well.


export interface ViewportAwareComponentProps {
/**
* Determines pre-triggering of inViewport. Useful for rendering components beforehand to improve user experience. A ratio of 0.5 means that the effective viewport will be twice the size of the real viewport.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should probably be split into several lines.

export const Viewport = {
Tracker: ViewportTracker,
Aware: (component: typeof React.Component) => ViewportAware,
WithPlaceholder: (image: React.Component, placeholder: React.Component) => ViewportAwarePlaceholder
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wrapped component can be something other than image as well, so I would replace image with component. Also, the placeholder argument should be optional.


export const Viewport = {
Tracker: ViewportTracker,
Aware: (component: typeof React.Component) => ViewportAware,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is typeof necessary and if so, why isn't it used one line below, for the WithPlaceholder HoC as well?

*/
innerRef?: React.Ref
}
export class ViewportAware<P> extends React.Component<ViewportAwareComponentProps & P> {}
Copy link
Collaborator

@bevkoski bevkoski Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all of the classes and interfaces exported? Isn't the const Viewport export at the bottom sufficient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants